/**
 * @author Linrui
 * @since 2010.04.30
 * 用户个人管理页面
 */
package com.qeado.user.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.qeado.user.model.User;
import com.qeado.user.service.UserService;

@Scope("session")
@Controller
public class UserManageAction extends ActionSupport {
	
	@Autowired
	private UserService userService;
	
	private String status = null ; // 返回状态

	private User userDTO; // use for user register and user login
	
	public User getUserDTO() {
		return userDTO;
	}

	public void setUserDTO(User userDTO) {
		this.userDTO = userDTO;
	}

	public String getStatus() {
		return status;
	}

	@Override
	public String execute() throws Exception {
		userDTO = (User)ActionContext.getContext().getSession().get("login_user");
		status = null;
		return super.execute();
	}
	
	/* update user */
	public String updateUser() throws Exception{
		if( userService.updateUser(userDTO) ) {
			status = "资料修改成功";
			return "success";
		} else {
			status = "资料修改失败";
			return "visit_fail"; 
		}		
	}
	
}
